{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "36f6b62e-5505-42e0-bc33-6119bb1e3b8e",
   "metadata": {},
   "outputs": [],
   "source": [
    "from IPython.display import Image"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "88ded059-af1a-4433-8356-1a806f8a8e2c",
   "metadata": {},
   "source": [
    "- https://github.com/harry0703/AudioNotes.git"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "32980ce2-581b-47dd-aa5e-884a2c80c232",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<img src=\"./imgs/audio-notes-framework.png\" width=\"400\"/>"
      ],
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Image(url='./imgs/audio-notes-framework.png', width=400)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "21f3d25d-d355-4dc9-bfd1-abd8a70572b8",
   "metadata": {},
   "source": [
    "```python\n",
    "@cl.on_chat_start\n",
    "async def on_chat_start():\n",
    "    ...\n",
    "    asr_result = await transcribe_file(file)\n",
    "    await summarize_notes(asr_result)\n",
    "    await msg.send()\n",
    "    ...\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "afdc3984-10fe-475e-9e3c-2d715b6d26b9",
   "metadata": {},
   "source": [
    "### transcribe_file"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "952f14be-b122-42ce-b6cf-924cbf80644e",
   "metadata": {},
   "source": [
    "```python\n",
    "from funasr import AutoModel\n",
    "...\n",
    "    self.__model = AutoModel(model=\"paraformer-zh\",\n",
    "        vad_model=\"fsmn-vad\",\n",
    "        punc_model=\"ct-punc\",\n",
    "        spk_model=\"cam++\",\n",
    "        log_level=\"error\",\n",
    "        hub=\"ms\"  # hub：表示模型仓库，ms为选择modelscope下载，hf为选择huggingface下载。\n",
    "    )\n",
    "```\n",
    "\n",
    "- `~/.cache/modelscope/hub/models`"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5aa79b0e-a282-4471-898a-f2f15b8bf703",
   "metadata": {},
   "source": [
    "### chat "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a024a88-ff8f-4bfb-80b2-3f7bcfdca6e4",
   "metadata": {},
   "source": [
    "```python\n",
    "async def summarize_notes(text):\n",
    "    messages = [\n",
    "        {\"role\": \"system\", \"content\": \"你是一名笔记整理专家，根据用户提供的内容，整理出一份内容详尽的结构化的笔记\"},\n",
    "        {\"role\": \"user\", \"content\": text},\n",
    "    ]\n",
    "```"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
